package com.meituan.mapper;

import com.meituan.model.OrderDetailEntity;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface OrderDetailMapper {

//    @Insert("insert into order_detail(order_id,goods_id,goods_name,goods_price,goods_img) values(orderId,goodsName,goodsPrice,goodsImg)")
    @Insert("<script>insert into order_detail(order_id,goods_id,goods_name,goods_price,goods_img) values" +
            "<foreach collection='goodsList' item='goods' separator=','>" +
            "(#{orderId},#{goods.goodsId},#{goods.goodsName},#{goods.goodsPrice},#{goods.goodsImg})" +
            "</foreach></script>")
    Integer save(@Param("orderId") String orderId,@Param("goodsList") List goodsList);

    @Select("select * from order_detail where order_id = #{orderId}")
    List<OrderDetailEntity> findById(String orderId);

}
